<?php


/**
 * 
 * @author szm
 */
class Grammar_model  extends CI_Model  {
    public function __construct(){
        parent::__construct();
        $this->load->database();
    }
    public function getGrammars($lessonIds=0){
    	try{
	        if(empty($lessonIds)){
	            return array();
	        }
	        if(!is_array($lessonIds)){
	            $lessonIds=array($lessonIds);
	        }
	        $lessonIds=implode(",",$lessonIds);
	        $this->db->select('*');
	        $this->db->from('grammar as gs');
	        $this->db->join('sentence  as ss','gs.sentence_id=ss.sentence_id' ,'inner');
	        $this->db->join('sentence_source_1 as sc', 'sc.sentence_id  = ss.sentence_id ', 'left');
	        $this->db->where_in('ss.lesson_id',$lessonIds);
	        $result=$this->db->get();
	        $rs=$result->result_array();
	        return $rs;

	     }catch(Exception $e){
            return array();
         }
    }
    public function listAllGrammars(){

    }
    
    public function getGrammar(){

    }
    
    public function saveGrammar(){


    }
    
    public function removeGrammar(){

    }
}

